package info.peigen.hotpot.component.pay.wechat.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import org.apache.commons.lang3.StringUtils;
import org.noear.solon.Solon;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Import;
import org.noear.solon.annotation.Inject;
import org.noear.solon.core.bean.LifecycleBean;

/**
 * @author Binary Wang
 */
@Configuration
@Import(scanPackages = {"info.peigen.hotpot.component.pay.wechat"})
public class WxPayConfiguration implements LifecycleBean {
    @Inject
    private WxPayProperties properties;

    @Override
    public void start() throws Throwable {
        WxPayService bean      = Solon.context().getBean(WxPayService.class);
        WxPayConfig  payConfig = bean.getConfig();
        payConfig.setNotifyUrl(StringUtils.trimToNull(this.properties.getNotifyUrl()));
    }
}
